﻿@using SmartStore.Web.Models.Customer;
@model CustomerAvatarModel
@{
    if (!Model.AvatarColor.HasValue())
    {
        Model.AvatarColor = "light";
    }
}

<div class="@(Model.Large ? "customer-avatar-lg" : "customer-avatar")">
    @if (Model.AllowViewingProfiles)
    {
        <a class="avatar-link" href="@Url.RouteUrl("CustomerProfile", new { id = Model.Id })">@Avatar()</a>
    }
    else
    {
        @Avatar()
    }
</div>

@helper Avatar()
{
    var textColor = Model.AvatarColor == "light" ? "text-muted" : "text-light";

    if ((Model.FileId ?? 0) != 0)
    {
        <img class="avatar-img" src="@Url.Media(Model.FileId, Model.AvatarPictureSize, null, false)" title="@Model.UserName" />
        <span class="avatar-letter d-none bg-@(Model.AvatarColor) @(textColor)" title="@Model.UserName">
            @Model.AvatarLetter
        </span>
    }
    else
    {
        <img class="avatar-img d-none" src="#" title="@Model.UserName" />
        <span class="avatar-letter bg-@(Model.AvatarColor) @(textColor)" title="@Model.UserName">
            @Model.AvatarLetter
        </span>
    }
}